import sys
sys.path.append('../kernel')
from model import Model
class Phone_m(Model):
    table='phone'
    def __init__(self):
        # 链接数据库
        super().__init__()

    # 添加城市酒店url
    def add_city_hotel_url(self,url,title,count):
        sql = "INSERT INTO " + self.table + " SET `url`='%s',title='%s',count='%d'" % (url,title,count)

        self.cursor.execute(sql)
        self.conn.commit()  # 提交

    # 根据url获取信息
    def get_xcurl_by_url(self,url):
        sql = "SELECT * FROM " + self.table + " WHERE url='%s'" % url
        self.cursor.execute(sql)
        data = self.cursor.fetchone()
        return data
    def __del__(self):
        #计数数据库链接
        self.cursor.close()
        self.conn.close()
